package com.caiyouxi.boss.buser.controller;

import com.caiyouxi.boss.buser.model.SysDepartmentsBean;
import com.caiyouxi.boss.buser.service.SysDepartmentsService;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.control.BaseController;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Administrator on 2017/10/25.
 */
@RestController
@RequestMapping("/boss/departments")
public class SysDepartmentsController extends BaseController {

    private Logger logger = Logger.getLogger(SysDepartmentsController.class);

    @Autowired
    private SysDepartmentsService sysDepartmentsService;

    //获取部门信息
    @RequestMapping("/get_list")
    public ResData show_departments(HttpServletRequest request, HttpServletResponse response , SysDepartmentsBean bean){
        logger.info("get_list");

        return sysDepartmentsService.get_all_departments(bean);
    }

    //添加部门信息
    @RequestMapping("/add_departments")
    public ResData add_departments(HttpServletRequest request, HttpServletResponse response, @RequestBody SysDepartmentsBean bean){
        logger.info("add_departments");

        return sysDepartmentsService.add_departments(bean);
    }


    //查询部门信息BY id
    @RequestMapping("/get_depart_by_id")
    public ResData get_departments_id(HttpServletRequest request, HttpServletResponse response,  @RequestBody SysDepartmentsBean bean){
        logger.info("get_depart_by_id");
        return sysDepartmentsService.get_departments_by_id(bean);
    }


    //修改部门信息
    @RequestMapping("/update_departments")
    public ResData update_departments(HttpServletRequest request, HttpServletResponse response,  @RequestBody SysDepartmentsBean bean){
        logger.info("update_departments");
        return sysDepartmentsService.update_departments(bean);
    }







}
